package com.hom.test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

//本类用于输出（写出）演示
public class Hom1 {
    public static void main(String[] args) {
        try {
            File file = new File("D:\\ioliu\\Test1.txt");

            if(!file.exists()){
                file.createNewFile();
            }
            //对象输出流是一个字节处理器，所以需要一个字节节点流来构建对象
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file,true));
            Student stu = new Student("Tom",20,"男");
            oos.writeObject(stu);
            oos.flush();//清空缓存区

            oos.close();
        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
